package io.github.zhonglunsheng.common;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Slf4j
public class ZipUtil {

    public static void unzipFile(String zipPath, String descDir) throws IOException {
        cn.hutool.core.util.ZipUtil.unzip(zipPath, descDir);
    }

    public static void zipFiles(String zipPath, String targetPath) {
        /**
         * public static File zip(String srcPath, String zipPath, Charset charset, boolean withSrcDir) throws UtilException {
         */


        cn.hutool.core.util.ZipUtil.zip(zipPath, targetPath, StandardCharsets.UTF_8,
                false
        );
    }

    //测试方法
    public static void main(String[] args) throws IOException {

        String zipPath = "D:/test/npm.zip";
        String descDir = "D:/test/";

        unzipFile(zipPath, descDir);
//        zipFiles("D:/test/npm", "D:/test/233.zip");
    }
}
